package com.lan.parse;

import com.lan.model.Symbol;
import com.lan.model.symbol.*;

import java.util.ArrayList;
import java.util.List;

public class SymbolTree {

    private Symbol symbol;

    private List<Symbol> symbols;

    public SymbolTree(Symbol symbol) {
        this.symbol = symbol;
    }

    public Scope getScope() {
        if (symbol instanceof Scope) {
            return (Scope) symbol;
        }
        return null;
    }

    public Block getBlock() {
        if (symbol instanceof Block) {
            return (Block) symbol;
        }
        return null;
    }


    public List<Symbol> getSymbols() {
        return symbols;
    }

    public void setSymbols(List<Symbol> symbols) {
        this.symbols = symbols;
    }

    public void put(Symbol symbol) {
        if (symbols == null) {
            symbols = new ArrayList<>();
        }
        symbols.add(symbol);
    }
}
